package htime

import (
	"regexp"
	"time"
)

func init() {
	Register(NewHDateTime())
}

// 1000-01-01 00:00:00至9999-12-31 23:59:59
// 2022-10-22           ========> 2022-10-22 00:00:00
// 2022-10-22 11        ========> 2022-10-22 11:00:00
// 2022-10-22 11:11     ========> 2022-10-22 11:11:00
// 2022-10-22 11:11:30  ========> 2022-10-22 11:11:30
type hdate_time struct {
	*regexp.Regexp
}

func NewHDateTime() StrToTime {
	return &hdate_time{
		Regexp: regexp.MustCompile(`^[1-9]\d{3}[\.\-\_/年](0{0,1}[1-9]|10|11|12)[\.\-\_/月](0{0,1}[1-9]|1[1-9]|2[1-9]|30|31)[日]{0,1} ([0-1]{1}\d{1}|20|21|22|23)[\:时]{0,1}([0-5]\d{1})[\:分]{0,1}([0-5]\d{1})[秒]{0,1}$`),
	}
}

func (h *hdate_time) Check(s string) bool {
	return h.FindStringIndex(s) != nil
}

func (h *hdate_time) Result(strTime *StrTime) *time.Time {
	//TODO implement me
	panic("implement me")
}
